package ru.gerunn.parsing;

import java.util.regex.Pattern;

import org.hibernate.Session;

import ru.gerunn.hibernate.util.HibernateUtil;
import ru.gerunn.parsing.service.LogParserRunnable;
import ru.gerunn.parsing.tables.ETDLog;
import ru.gerunn.parsing.tables.ETDOperation;
import ru.gerunn.parsing.tables.ETDType;
import ru.gerunn.parsing.tables.MEKLog;
import ru.gerunn.parsing.tables.MEKOperation;
import ru.gerunn.parsing.tables.MEKType;
import ru.gerunn.parsing.tables.SNTLog;
import ru.gerunn.parsing.tables.SNTOperation;
import ru.gerunn.parsing.tables.SNTType;

public class Main2 {

	public static void main(String[] args) {
		Session session = HibernateUtil.getSessionFactory().openSession();

		Runnable etdRunnable = new LogParserRunnable<ETDType, ETDOperation, ETDLog>(
				session,
				"CommonsQueryLoggingListener",
				Pattern.compile("^(.*),\\d\\d\\d WARN \\[net\\.ttddyy\\.dsproxy\\.listener\\.CommonsQueryLoggingListener] - ;(\\d+) ;.*; \\[(.*)\\] ;(.*)$"),
				ETDType.class,
				ETDOperation.class,
				ETDLog.class,
				"smb://10.0.0.145/public/Backups/WAS_logs.ETD/",
				"ETD-WARN"
				);

		Runnable mekRunnable = new LogParserRunnable<MEKType, MEKOperation, MEKLog>(
				session,
				"CommonsQueryLoggingListener",
				Pattern.compile("^(.*),\\d\\d\\d WARN \\[net\\.ttddyy\\.dsproxy\\.listener\\.CommonsQueryLoggingListener\\].*Time:(\\d+).*\\{\\[(.*)\\](\\[.*)$"),
				MEKType.class,
				MEKOperation.class,
				MEKLog.class,
				"smb://10.0.0.145/public/Backups/WAS_logs.MEK/",
				"ETD-WARN"
				);

		Runnable sntRunnable = new LogParserRunnable<SNTType, SNTOperation, SNTLog>(
				session,
				"CommonsQueryLoggingListener",
				Pattern.compile("^(.*),\\d\\d\\d WARN \\[net\\.ttddyy\\.dsproxy\\.listener\\.CommonsQueryLoggingListener\\].*Time:(\\d+).*\\{\\[(.*)\\](\\[.*)$"),
				SNTType.class,
				SNTOperation.class,
				SNTLog.class,
				"smb://10.0.0.145/public/Backups/WAS_logs.SNT/SNT/",
				"SNT-WARN"
				);

		Thread etdThread = new Thread(etdRunnable);
		Thread mekThread = new Thread(mekRunnable);
		Thread sntThread = new Thread(sntRunnable);

		etdThread.start();
		mekThread.start();
		sntThread.start();

		HibernateUtil.shutdown();
	}

}
